﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using csvmb.contracts;

namespace csvmb.csvadapter {
    public class Zeilen_lesen_ab_Zeile_2 : IZeilen_lesen_ab_Zeile_2 {
    public void Process(Tuple<string, int> message) {
        Trace.TraceInformation("Zeilen_lesen_ab_Zeile_2.Process aufgerufen mit {0} {1}" , message.Item1, message.Item2);

        var inFile = new StreamReader(message.Item1);
        string ersteZeile = inFile.ReadLine(); // Spalten wegwerfen

        var zeilen = new List<string>();
        do {
            zeilen.Add(inFile.ReadLine());
            if (zeilen.Count >= message.Item2) {
                break;
            }
        }
        while (! inFile.EndOfStream );
        inFile.Close();

        Result(zeilen);
        }

        public event Action<IEnumerable<string>> Result;
    }
}
